{% extends 'base-layer.html' %}
{% load staticfiles %}

{% block css %}
<link rel="stylesheet" href="{%static 'plugins/select2/select2.min.css' %}">
<link rel="stylesheet" href="{% static 'js/plugins/layer/skin/layer.css' %}">
<link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap-datetimepicker.min.css' %}">
<link rel="stylesheet" href="{% static 'plugins/fileinput/fileinput.css' %}">

{% endblock %}
{% block main %}
<div class="box box-danger">
	<form class="form-horizontal" id="addForm" method="post">
		{% csrf_token %}
        <input name='id' type="hidden" value="{{ work_order.id }}" />
        <div class="box-body">
          <fieldset>
            <div class="form-group has-feedback">
                <label class="col-sm-2 control-label">文件上传</label>
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="file_content" name="file_content" class="form-control" type="file"/>
                    </div>
                </div>
            </div>
          </fieldset>
            <fieldset>
                <div class="form-group has-feedback">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-8">
                        <small class="text-red">文件上传格式.zip压缩文件，文件最大为50M，只有填写过执行记录才可以上传文件</small>
                        <small class="text-ret"><strong><p>备注：上传配置资料需先填写执行记录后再上传文件</p></strong></small>
                    </div>
                </div>
            </fieldset>
        </div>
    </form>
</div>

{% endblock %}

{% block javascripts %}
<script src="{% static 'plugins/fileinput/fileinput.js' %}"></script>
<script src="{% static 'plugins/fileinput/zh.js' %}"></script>
<script type="text/javascript">


// 获取表单数据


//上传文件

$(document).on('ready', function() {
    $("#file_content").fileinput({
        language: "zh",
        showPreview: false,
        showUpload: true,
        allowedFileExtensions: ["zip"],
        uploadUrl: "{% url 'personal-workorder-upload' %}",
        uploadExtraData: {
            'csrfmiddlewaretoken': '{{ csrf_token }}',
            'id': '{{ work_order.id }}',
        },
        maxFileCount: 1,
        maxFileSize: 51200,
    });
});

</script>

{% endblock %}
